<?php $addCallbackRuntime = uniqid('treeviewAddCallback');?>
<?php $delCallbackRuntime = uniqid('treeviewDelCallback');?>
<?php $sortCallbackRuntime = uniqid('treeviewSortCallback');?> {:W('Tree/render',array($nodes,array('title'=>'后台菜单'),I('get.menu.id'),array('expendLevel'=>2,'showAdd'=>$addCallbackRuntime,'showDel'=>$delCallbackRuntime,'categoryEndNode'=>true,'showSort'=>$sortCallbackRuntime)))}
<script>
	var {$addCallbackRuntime} = function (el) {
		var url = "{:U('add')}";
		var seperator = url.search(/\?/) >= 0 ? '&' : '?';
		url += seperator + '' + 'pid=' + el.attr('data-id');
		window.location.href = url;
		return false;
	};

	var {$delCallbackRuntime} = function (el) {
		var url = "{:U('del')}";
		var seperator = url.search(/\?/) >= 0 ? '&' : '?';
		url += seperator + '' + 'ids=' + el.attr('data-id');
		popup.confirm(
			"确定要删除这个菜单么?",
			function () {
				$.get(url, {}, function () {
					popup.tip('删除成功');
					el.closest('li').remove();
				});
			});
		return false;
	};

	var {$sortCallbackRuntime} = function (treeviewEl) {
		var data = [];
		var flag = 'sort';
		var el,id;

		treeviewEl.find('li').each(function(i){
			id = $(this).children('span.treeview-item-box').attr('data-id');
			if(id!==undefined){
				data.push({'id':id,'sort':i});
			}
		});

		$.ajax({
			'url': '{:U("menu/index")}',
			'data': { data: data, flag: flag },
			'type': 'post',
			'dataType': 'json',
			'success': function (info) {
				if (!info.status) {
					popup.tip(info.info);
				}
			},
			'error': function () {
				popup.tip('系统错误');
			}
		});
	}

</script>